<?php

declare(strict_types=1);

namespace App\Model\Admin;

use App\Traits\Model\Admin\AdminLog as AdminLogTraits;
use App\Model\Model;

/**
 * @property int $id 
 * @property int $out_id 外键
 * @property string $model 模型
 * @property int $admin_id 用户ID
 * @property string $app 应用
 * @property int $ip IP
 * @property string $user_agent 用户代理
 * @property int $type 操作类型|{"1":"查看","2":"新增","3":"编辑","4":"导出","5":"登录","6":"修改密码","7":"删除"}
 * @property string $desc 详情
 * @property string $modular 模块
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 */
class AdminLog extends Model
{
    use AdminLogTraits;

    /**
     * The table associated with the model.
     */
    protected ?string $table = 'admin_log';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'out_id', 'model', 'admin_id', 'app', 'ip', 'user_agent', 'type', 'desc', 'modular', 'created_at', 'updated_at'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'out_id' => 'integer', 'admin_id' => 'integer', 'ip' => 'integer', 'type' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime'];

    /**
     * 自动新增
     * @var array|string[]
     */
    public array $insert = ['admin_id', 'app', 'user_agent', 'ip'];

    /**
     * The accessors to append to the model's array form.
     * @var array|string[]
     */
    protected array $appends = ['desc_text'];
}
